<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="qwe1" onclick="console.log(123)">
    <p>段1</p>
    <p id="op"></p>
    <p>段3</p>
    <p>段4</p>
    <p id="pp"><span id="ppd">ss</span></p>
    <p>段5</p>
    <p>段6</p>
    <p>段7</p>
    <div>iiii</div>
  </div>
  <script src="./cs.js"></script>
  <script>
       var dv =cs$("qwe1");
        var pv = cs$("op");
        var ppv = cs$("pp");
        var ppvd = cs$("ppd")
    // 判断是否有 子节点的方法
      // 判断该元素是否有子节点
        // 不区分节点类型
      console.log(dv.hasChildNodes());
      console.log(pv.hasChildNodes());
      // 判断当前节点是否有子节点
      dv.firstChild !== null
      console.log(dv.firstChild !== null);
      console.log(pv.firstChild !== null);
      //方法2通过集合长度判断
      dv.childNodes.length > 0;
      console.log(dv.childNodes.length > 0);
      console.log(pv.childNodes.length > 0)
      // 子元素节点是否存在
      console.log(dv.children.length > 0);
      console.log(dv.children.length );
      console.log(dv.children);
      console.log(dv.contains());
      // 判断是否为某个节点的后代节g
      console.log(dv.contains(pv));
      console.log(dv.contains(ppvd));
      console.log(pv.contains(dv));

      // 
  </script>
</body>
</html>